import ajax from '../utils/request.js'
import { getUser } from '../utils/storage'

// 内容管理页根据传入的参数 按需获取指定数据
export const getContentData = params => {
  return ajax({
    method: 'get',
    url: '/mp/v1_0/articles',
    params
  })
}
// 删除文章
export const delContent = data => {
  const { target } = data
  return ajax({
    url: `mp/v1_0/articles/${target}`,
    method: 'delete',
    headers: {
      Authorization: `Bearer ${getUser().token}`
    }
  })
}
// 搜索文章
export const searchArticles = params => {
  return ajax({
    url: 'mp/v1_0/search',
    headers: {
      Authorization: `Bearer ${getUser().token}`
    },
    params
  })
}
// 获取文章频道
export const getChannels = params => {
  return ajax({
    url: 'mp/v1_0/channels',
    params
  })
}
